home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / TB_XMODE.ZIP / UNCHAIN.TXT < prev    next >
Encoding:
Text File  |  1995-07-05  |  27.8 KB  |  560 lines

  1. █████████████▐ Ex-planed (;)) ███▐                ██████████████  ██████████████
  2. █████████████▐                ███▐                    ██████          ██████
  3. ███▐ ███▐ ███▐                ███▐         █▀▄ █▀▄ █▀▄ ██████        ██████
  4. ███▐ ███▐ ███▐                ███▐          ▄█   █ █ █   █████      █████
  5. ███▐ ███▐ ███▐                ███▐         ▄ █ █▀  █ █     ████    ████
  6. ███▐ ███▐ ███▐                ███▐          ▀▀  ▀▀  ▀▀      ████  ████
  7. ███▐ ███▐ ███▐                ███▐         █ ▄ █▀▄ █▀▄        ██████
  8. ███▐      ███▐                ███▐         ▀▄█ █ █ █ █         ████
  9. ███▐      ███▐ ████████▐ ████████▐ █████▐    █ █ █ █ █         ████
  10. ███▐      ███▐ ████████▐ ████████▐ █████▐    ▀  ▀▀  ▀▀        ██████
  11. ███▐      ███▐ ███▐ ███▐ ███▐ ███▐ ████    █▀▄ █▀  █▀       ████  ████
  12. ███▐      ███▐ ███▐ ███▐ ███▐ ███▐ █████▐    █ ▀▄  █▀▄     ████    ████
  13. ███▐      ███▐ ███▐ ███▐ ███▐ ███▐ █████▐  █▀    █ ▀▄█   █████      █████
  14. ███▐      ███▐ ███▐ ███▐ ███▐ ███▐ ████     ▀▀  ▀      ██████        ██████
  15. ███▐      ███▐ ████████▐ ████████▐ █████▐             ██████          ██████
  16. ███▐      ███▐ ████████▐ ████████▐ █████▐         ██████████████  ██████████████
  17. ───────────────────────────────═ The Bitripper ═────────────────────────────────
  18.  
  19. Ok guys, for the re-bound. Here's The Bitripper bringing you, coders all over,
  20. _*THE*_ invitation to the so-called tweaked modi. Well, actually this is only
  21. describing the 320x400x256 mode, but there are enough trainers to cover the lack
  22. of this one. BTW, this one is only meant to correct some mistakes which I found
  23. through many trainers, it's not a complete guide on the VGA programming subject.
  24. If you want a complete guide, buy a good book (a thing with papers stuck inside
  25. a hard cover). E.g. Programmers Guide to the EGA/VGA, Richard E. Ferraro,
  26. PC Intern 4, or use some all-round hypertexts, e.g. HelpPC, Tech!Help.
  27.  
  28. Assumptions: knowledge of ASM, color VGA card in possession, 16-bit programming,
  29.              little knowledge of VGA registers and ports programming
  30.  
  31. Enclosed in this package should be the following files:
  32.  
  33. UNCHAIN.TXT  - This textfile
  34. XMODE.ASM    - Example code, changing to XMODE and displaying a 256 color
  35.                picture two times
  36. PALETTE.INC  - Palette for picture shown by XMODE.ASM (is included and must be
  37.                in the same directory)
  38. PICTURE.INC  - Picture shown by XMODE.ASM (is included and must be in the same
  39.                directory)
  40. DESCRIPT.ION - 4DOS Description file
  41. MAKEFILE.    - MakeFile for Borland's MAKE utility
  42. XMODE.EXE    - Compiled and packed version of XMODE.ASM
  43. FILE_ID.DIZ  - File ID for BBS's, please do not remove
  44.  
  45.  
  46. ┌──────────────────────────────────────────────────────────────────────────────┐
  47. │░▒▓█ INTRODUCTION █▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
  48. └──────────────────────────────────────────────────────────────────────────────┘
  49.  
  50. Let me introduce you into my experience with learning about the so-called
  51. tweaked modi (hereafter: xmode).
  52.  
  53. When I first started to have a look at the xmode, it was basically coz' many of
  54. other productions were using the xmode mainly due to it's higher resolutions.
  55. Everybody was using the xmode, so there had to be something very special about
  56. it, and I got very interested in learning every aspect of the xmode.
  57.  
  58. I got myself a book (borrowed from a friend of mine). A very good book actually,
  59. the Programmers Guide to the EGA/VGA second edition of Richard E. Ferraro.
  60. In it, there was a total, bug-free description of each VGA register and the way
  61. each part of yar VGA card works. I used it as a reference while I was examining
  62. the xmode code of other programmers and while reading the trainers about the
  63. subject.
  64.  
  65. I encountered some slight problems while implementing the ideas I got from all
  66. the different trainers. For example, I got myself running into the double-word
  67. modus over and over again because I was anxious to know every bit (literally!)
  68. of the code changing the normal BIOS mode 13h into xmode before I would use it
  69. (as I do with all the rest of the effects etc.).
  70.  
  71. So, when my friend needed his book back, and I still hadn't found out what the
  72. double-word modus was about, there was some kind of disappointment.
  73.  
  74. That was until I bought myself PC Intern 4, and started to read in it.
  75. Although, there are quite a few mistakes, even faults and don't mention errors
  76. in the book. With the help of some hypertexts and the PC Game Programmers
  77. Encyclopedia I finally found out what _*EXACTLY*_ this double-word modus
  78. was about.
  79.  
  80. But hey, enough of this crap. Let's get ya all back to business with the xmode
  81. explanation.
  82.  
  83. Press cursor down key when ready... ;)
  84.  
  85.  
  86. ┌──────────────────────────────────────────────────────────────────────────────┐
  87. │░▒▓█ BIOS MODE 13h vs. XMODE █▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
  88. └──────────────────────────────────────────────────────────────────────────────┘
  89.  
  90. The xmode has (obviously) advantages above the BIOS mode. Unfortunately, it also
  91. has some disadvantages which must be taken into account when choosing which mode
  92. is going to be used. XMode is not all of the time recommended. I'll show you:
  93.  
  94. Advantages for BIOS mode 13h:
  95. - Can address all pixels in one segment.
  96. - No need for handling the read/write plane coz' it's automatically selected for
  97.   you (plane number is taken from the offset).
  98. - No need for more code to initialize, only one call to standard BIOS
  99.   video interrupt.
  100.  
  101. Disadvantages for BIOS mode 13h:
  102. - Only one page for displaying graphics, so no page-flipping can be performed in
  103.   the VGA memory itself.
  104. - Low resolution, 320x200 (although it's actually 320x400, as you'll see l8ron).
  105. - 192 kB of VGA memory is wasted due to the easy accessibility.
  106.  
  107.  
  108. Advantages for XMODE:
  109. - Page flipping can be performed using the VGA memory.
  110. - Up to 4 pages can be used.
  111. - Any resolution can be set by programming the VGA registers directly.
  112. - Scrolling of large pictures is easier.
  113.  
  114. Disadvantages for XMODE:
  115. - Every pixel read/write must be directed to one or more planes.
  116. - Extra code to initialize xmode.
  117.  
  118.  
  119. ┌──────────────────────────────────────────────────────────────────────────────┐
  120. │░▒▓█ VGA HARDWARE █▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
  121. └──────────────────────────────────────────────────────────────────────────────┘
  122.  
  123. The VGA memory consists of four 64 kB planes (see them as large arrays).
  124. In normal BIOS - or 'chained' - mode, these planes are chained together
  125. so that an easy addressing is possible, eliminating the need of specifying each
  126. plane before writing to or reading from it. Planes are numbered from 0 to 3.
  127.  
  128. For each offset you write to or read from, the two lowest bits of the offset
  129. are used to determine the plane to write to or read from. If, for example, you
  130. write a byte with value 0fh to offset 5h, what plane would it end up ?
  131. Well, take a look at the example:
  132.  
  133. Offset 0005h = 0000 0000 0000 0101b
  134.                                 ^^
  135. The lowest two bits of the offset address are 01b, which equals 1.
  136.  
  137. Then, the offset is shifted two bits to the right to loose the plane bits.
  138.  
  139. Offset 0001h = 0000 0000 0000 0001b
  140.  
  141. To determine the offset within the given plane, the offset is shifted two bits
  142. to the left:
  143.  
  144. Offset 0004h = 0000 0000 0000 0100b
  145.  
  146. Thus, writing 0fh to offset 5h in the video memory area results in writing 0fh
  147. to plane 1 at offset 4h within that plane.
  148.  
  149. When the BIOS mode is initialized, the memory looks like this (where the numbers
  150. in the different planes corresponds to the numbers in the video memory area):
  151.  
  152. 0                                                                         319
  153. ┌───────────────────────────────────────────────────────────────────────────┐  0
  154. │01234567                                                                   │
  155. │                                                                           │
  156. ·                                                                           ·
  157. ·                                                                           ·
  158. ·                                                                           ·
  159. │                                                                           │
  160. └───────────────────────────────────────────────────────────────────────────┘199
  161. Video memory area as 'seen' by the coder (this is actually also the VGA memory)
  162.  
  163.  
  164.          Plane 3 ┌01234567─────────────────────────────────────────────────────┐
  165.            (11b) │3░░░7░░░                                                     │
  166.                  │                                                             │
  167.                                                                                │
  168.       Plane 2 ┌01234567─────────────────────────────────────────────────────┐  │
  169.         (10b) │2░░░6░░░                                                     │  │
  170.               │                                                             │  │
  171.                                                                             │  │
  172.    Plane 1 ┌01234567─────────────────────────────────────────────────────┐  │  │
  173.      (01b) │1░░░5░░░                                                     │  │  │
  174.            │                                                             │  │  │
  175.                                                                          │  │
  176. Plane 0 ┌01234567─────────────────────────────────────────────────────┐  │  │
  177.   (00b) │0░░░4░░░                                                     │  │  │
  178.         │                                                             │  │  │
  179.         │                                                             │  │
  180.         │                                                             │  │
  181.         │                                                             │  │
  182.         │                                                             │
  183.         │                                                             │
  184.         │                                                             │
  185. Real plane dividing in the memory of the VGA (chained mode, double-word mode)
  186.  
  187. The '░' denotes an empty, unused byte. You see, for each four bytes in a plane,
  188. 3 bytes are not used. As each plane contains 320*200 bytes and there are four
  189. planes, there are 320*200*4 bytes = 256000 bytes total of which ¼ is used.
  190.  
  191. So, actually, ¼ of a plane is used, which equals ± 16 kB. The bytes are all over
  192. a plane, with gaps of three bytes between them. As the planes and offsets
  193. within planes are automatically selected, we can't use the gaps for any other
  194. data. Thus, in order to get more than one display page, we must get rid of the
  195. gaps between the data (or, make them smaller) !
  196.  
  197.  
  198. ──────═ Chain4, Odd/Even, Linear ═──────────────────────────────────────────────
  199.  
  200. When the standard BIOS mode is invoked, the chain4 mode is used. Chain4
  201. mode is explained above. There is the odd/even mode too, where there's also a
  202. sort of automatic selection of the plane and the offset within the plane. In
  203. odd/even mode, the lowest bit (LSB) of the offset address together with the page
  204. bit in the miscellaneous register of the graphics controller is used to
  205. determine the plane and offset in a kind of similar way as chain4 does that.
  206. Odd/even mode is not interesting enough to describe here in detail.
  207.  
  208. As we want to address all of the 256 kB memory of the VGA card, we are not going
  209. to use the chain4 mode, nor the odd/even mode. We are going to set the VGA card
  210. to use a sort of linear mode, so we can address every single byte in a plane.
  211. That will give us access to 256 kB memory. While we are able to address all
  212. memory, we can then use four different display pages (at a resolution of
  213. 320x200).
  214.  
  215.  
  216. ──────═ Double-word, word, byte ═───────────────────────────────────────────────
  217.  
  218. In BIOS mode, double-word mode is set. This means, for each information byte,
  219. there are four bytes to be read (two bytes is a word, four bytes is a
  220. double-word). The VGA card has the opportunity to use one of its three modes:
  221. Double-word mode, word mode and byte mode. In odd/even mode, word mode should be
  222. used. For our purposes (four display pages), byte mode should be used, as the
  223. bytes in the planes will succeed each other, with no gaps.
  224.  
  225. In short: if double-word mode is set, there are four bytes to read each time one
  226. information byte is wanted. In word mode, there's need to read two bytes of
  227. which one is containing real information. In byte mode, one byte needs to be
  228. read as each separate byte contains information.
  229.  
  230. As a nasty result (sometimes handy), we will have to tell the VGA to which plane
  231. we will write, because the offset no longer gets shifted to determine the plane
  232. and offset within the plane to write to.
  233.  
  234. Sometimes this comes in handy, because you can specify more than one plane to
  235. write to. You can, at utmost, set four pixels at the same time to the same
  236. color, by selecting all planes for writing and writing a byte to an offset.
  237. Think about this when you're starting to write code to quickly fill areas on
  238. your screen, for example polygons. With a simple stosb, you can set 4 pixels at
  239. one time, with a simple stosw you then can set 8 pixels to the same color at
  240. once. Or better: on a 386 or higher, you can use stosd. With stosd, you can set
  241. 16 pixels at once. Now, isn't that fast ?
  242.  
  243. To give you more grip on this, I'll exercise the extended ASCII charset again:
  244.  
  245.          Plane 3 ┌01234567─────────────────────────────────────────────────────┐
  246.            (11b) │37                                                           │
  247.                  │                                                             │
  248.                                                                                │
  249.       Plane 2 ┌01234567─────────────────────────────────────────────────────┐  │
  250.         (10b) │26                                                           │  │
  251.               │                                                             │  │
  252.                                                                             │  │
  253.    Plane 1 ┌01234567─────────────────────────────────────────────────────┐  │  │
  254.      (01b) │15                                                           │  │  │
  255.            │                                                             │  │  │
  256.                                                                          │  │
  257. Plane 0 ┌01234567─────────────────────────────────────────────────────┐  │  │
  258.   (00b) │04                                                           │  │  │
  259.         │                                                             │  │  │
  260.         │                                                             │  │
  261.         │                                                             │  │
  262.         │                                                             │  │
  263.         │                                                             │
  264.         │                                                             │
  265.         │                                                             │
  266. Real plane dividing in the memory of the VGA (unchained mode, byte mode)
  267.  
  268. As you see, one offset now denotes four pixels. As mentioned before, you'll have
  269. to select which planes to write to before setting a pixel.
  270.  
  271.  
  272. ──────═ Four different pages ═──────────────────────────────────────────────────
  273.  
  274. Now, we have room for four different pages, we can also select them, but how to
  275. display each page ?
  276.  
  277. There are two registers, which together hold the offset in the video area to
  278. begin displaying at. As each screen is 320x200 big, it needs 64 kB.
  279. 64 kB is divided over four planes per screen, so a page needs 64000 / 4 = 16000
  280. offsets for being set-up. The first page starts at offset 0000h, the second at
  281. 4000h, the third at 8000h and the fourth at 0c000h.
  282.  
  283. To accommodate this for your set pixel routine, you can add the offset value
  284. divided by 10h to your segment address, so you don't have to bother about the
  285. starting offset anymore. You simply set your segment to 0a000h for page 0,
  286. to 0a400h for page 1, to 0a800h for page 2 and 0ac00h for page three.
  287. Then, offsets for a page are valid from 0000h to 3e80h.
  288.  
  289.  
  290. ──────═ Writing to or reading from one of the pages ═───────────────────────────
  291.  
  292. Writing to a plane is done by first selecting the plane(s) to which to write,
  293. and then writing a byte to a chosen offset. You can select the plane by using
  294. the map mask register of the sequencer controller. It is build as follows:
  295.  
  296.   7   6   5   4   3   2   1   0
  297. ┌───┬───┬───┬───┬───┬───┬───┬───┐
  298. │               │   │   │   │   │
  299. └───┴───┴───┴───┴───┴───┴───┴───┘
  300.   │           │   │   │   │   │
  301.   └───────────┤   │   │   │   └── 0: No access to plane 0
  302.               │   │   │   │       1: Access to plane 0
  303.               │   │   │   └────── 0: No access to plane 1
  304.               │   │   │           1: Access to plane 1
  305.               │   │   └────────── 0: No access to plane 2
  306.               │   │               1: Access to plane 2
  307.               │   └────────────── 0: No access to plane 3
  308.               │                   1: Access to plane 3
  309.               └────────────────── Not used (0)
  310.  
  311. For reading operations, the read map select register of the graphics controller
  312. must be changed. This register's layout is:
  313.  
  314.   7   6   5   4   3   2   1   0
  315. ┌───┬───┬───┬───┬───┬───┬───┬───┐
  316. │                       │       │
  317. └───┴───┴───┴───┴───┴───┴───┴───┘
  318.   │                   │   │   │
  319.   └───────────────────┤   └───┴── Number of plane to read from
  320.                       │
  321.                       └────────── Not used (0)
  322.  
  323.  
  324. ──────═ Displaying different pages ═────────────────────────────────────────────
  325.  
  326. To display one of the pages, you must set the offset of a page in the two
  327. registers called Start Address High and Start Address Low of the CRT controller.
  328. The high byte of the offset is placed in the start address high register,
  329. the low byte in the start address low register.
  330.  
  331. You can write to another page than you're showing on the screen, using the
  332. technique described above. With that in mind, you can do page-flipping (i.e.
  333. draw something on one page, while displaying the other and then swapping them by
  334. displaying the one you were drawing on and the one you were showing and do it
  335. all again with the swapped pages) and hereby eliminating the flicker or vertical
  336. retrace which is often annoying our presentation. Note that this manner is a
  337. whole lot faster than copying 64 kB each time!
  338.  
  339.  
  340. ──────═ 320x400x256 ═───────────────────────────────────────────────────────────
  341.  
  342. Well, where is that 400 pixels y resolution I promised you ?
  343. This one is really unexpected (well, I mentioned it at the start of this
  344. trainer): on the VGA card, there actually isn't a 200 y-resolution available.
  345. Instead, to keep the addressing as simple as possible AND providing a 256 color
  346. mode within the 256 kB boundary, the makers of the VGA card have come up with,
  347. well, logic, but unexpected scheme. By the way, this is also the reason why the
  348. pixels in 320x200x256 mode look so, like squares (■■ ;)). The lines displayed
  349. from the memory are just being doubled as they are displayed on the screen.
  350. So, one line really occupies two lines on the screen. With this solution, the
  351. memory can contain only 200 lines, but the screen will display 400 lines.
  352.  
  353. Now we've unchained the planes, and are addressing them linear, we can set the
  354. VGA to display 400 lines very simple.
  355.  
  356. The maximum scanline register of the CRT controller is build in this manner:
  357.  
  358.   7   6   5   4   3   2   1   0
  359. ┌───┬───┬───┬───┬───┬───┬───┬───┐
  360. │   │   │   │                   │
  361. └───┴───┴───┴───┴───┴───┴───┴───┘
  362.   │   │   │   │               │
  363.   │   │   │   └───────────────┴── (Times-1) to copy a line on the screen
  364.   │   │   │
  365.   │   │   └────────────────────── EGA: No function
  366.   │   │                           VGA: Bit 9 of start vertical blanking register
  367.   │   └────────────────────────── EGA: No function
  368.   │                               VGA: Bit 9 of line compare register
  369.   └────────────────────────────── EGA: No function
  370.                                   VGA: 200 points doubling mode
  371.  
  372. Bits 0-4:       Times-1 to copy a line. If, for example, these have the value 5,
  373.                 all lines will be displayed four times, bringing the real
  374.                 displayed lines to 200 / 4 = 50 lines.
  375. Bit 5:          Bit 9 of the start vertical blanking register
  376. Bit 6:          Bit 9 of the line compare register
  377. Bit 7:          0 = line doubling off
  378.                 1 = line doubling on
  379.  
  380.  
  381. Now, two pages are left. One starting at 0a000h:0000h and the other at
  382. 0a000h:8000h. Or, with the accommodation: 0a000h:0000h and 0a800h:0000h.
  383.  
  384.  
  385. ──────═ Used registers ═────────────────────────────────────────────────────────
  386.  
  387. When switching over to xmode from within BIOS mode 13h, some of the VGA
  388. registers must be re-programmed. The registers used are:
  389.  
  390. From the CRT controller (controls the Cathode Ray Tube, or monitor):
  391. - Maximum scanline register             (9h)
  392. - Start address high byte              (0ch)
  393. - Start address low byte               (0dh)
  394. - Underline location register          (14h)
  395. - Mode control register                (17h)
  396.  
  397. From the sequencer controller (controls the way memory is being displayed):
  398. - Map mask register                     (2h)
  399. - Memory mode register                  (4h)
  400.  
  401. From the graphics controller (controls reading/writing to VGA memory):
  402. - Read map select register              (4h)
  403. - Graphics mode register                (5h)
  404. - Miscellaneous register                (6h)
  405.  
  406. The CRT controller is accessed through port 3d4h and 3d5h (mono: 3b4h and 3b5h).
  407. The sequencer controller is accessed through ports 3c4h and 3c5h.
  408. The graphics controller is accessed through ports 3ceh and 3cfh.
  409.  
  410.  
  411. ┌──────────────────────────────────────────────────────────────────────────────┐
  412. │░▒▓█ BIOS MODE 13h -> 320x400x256 █▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
  413. └──────────────────────────────────────────────────────────────────────────────┘
  414.  
  415. Follows: a complete step-by-step description of switching to the xmode,
  416.          using ASM code to help you implementing:
  417.  
  418. In the code, I use macro's for the ease. I don't have to re-type each block of
  419. statements (which reduces the errors). A macro is called by just typing its
  420. name. If there are parameters valid for a macro, you must specify it/them behind
  421. the macro's name, separated by ",".
  422. You'll see what I'm trying to say when you see the source code hereafter.
  423. Consider the following macro's:
  424.  
  425. Select          MACRO   Controller,Register
  426.                 mov     dx,controller           ; Select address register
  427.                 mov     al,register             ; to put register index number
  428.                 out     dx,al
  429.                 inc     dx                      ; Select data register
  430.                 in      al,dx                   ; Input current value to AL
  431.                 ENDM
  432.  
  433. Other           MACRO   Register
  434.                 dec     dx                      ; Select address register
  435.                 mov     al,register             ; to put register index number
  436.                 out     dx,al
  437.                 inc     dx                      ; Select data register
  438.                 in      al,dx                   ; Input current value to AL
  439.                 ENDM
  440.  
  441. Put             MACRO
  442.                 out     dx,al                   ; Save value of AL to register
  443.                 ENDM
  444.  
  445.  
  446.  
  447. To start, change to BIOS mode 13h using sub-function 0h of int 10h:
  448.  
  449.                 mov     ax,13h
  450.                 int     10h
  451.  
  452. Then, change the memory mode register so that the chain4 as well as the odd/even
  453. mode is disabled, but preserve the lowest two bits, coz' they are not of our
  454. concern:
  455.  
  456.                 select  seq_c,memory_mode
  457.                 and     al,00000011b            ; Clear & preserve lowest 2 bits
  458.                 or      al,00000100b            ; Chain4 & Odd/Even mode off
  459.                 put
  460.  
  461. Change the graphics mode register so that a linear mode is being used by
  462. clearing bit number 4, but preserve the rest of the bits. Again, they are not of
  463. our concern:
  464.  
  465.                 select  gfx_c,graphics_mode     ; Set linear mode
  466.                 and     al,11101111b
  467.                 put
  468.  
  469. We do the same thing in the miscellaneous register of the graphics controller,
  470. but we clear bit number 1 instead of bit 4:
  471.  
  472.                 other   miscellaneous           ; Set linear mode
  473.                 and     al,11111101b
  474.                 put
  475.  
  476. Remember, we had to change from double-word mode to byte mode by turning of
  477. double-word and word mode. We'll do this by clearing bit number 6 of the
  478. underline location register of the CRT controller for the double-word mode, and
  479. by setting bit number 6 of the mode control register of the same controller:
  480.  
  481.                 select  crt_c,underline_loc     ; Double-word mode off
  482.                 and     al,10111111b
  483.                 put
  484.  
  485.                 other   mode_control            ; Word mode off, byte mode on
  486.                 or      al,01000000b
  487.                 put
  488.  
  489. And last but not least, we turn off line doubling and line copying to get 400
  490. lines on a screen by clearing bit number 7 and bit number 3 to 0 of the maximum
  491. scanline register of the CRT controller:
  492.  
  493.                 other   max_scan_line           ; 320x400x256
  494.                 and     al,01110000b
  495.                 put
  496.  
  497. With the map mask register of the sequencer controller, we can control which
  498. planes to write to. As we want to clear all planes, we select all planes for
  499. writing by setting bit number 3 to 0:
  500.  
  501.                 select  seq_c,map_mask          ; All planes on for writing
  502.                 or      al,00001111b
  503.                 put
  504.  
  505. Finally, we're clearing all planes by writing a zero word 32768 times (setting
  506. all the 256 kB to zero) to the VGA segment 0a000h (thus, starting at page 0):
  507.  
  508.                 mov     ax,0a000h               ; Set ES to VGA segment (0a000h)
  509.                 mov     es,ax
  510.                 xor     di,di                   ; and DI to offset 0000h
  511.                 mov     cx,08000h               ; The number of words is 32768
  512.                 xor     ax,ax                   ; Put a zero word 32768 times to
  513.                 rep     stosw                   ; ES:DI
  514.  
  515.  
  516.  
  517. That's all there is !
  518.  
  519. Now, you're ready to get exciting and beautiful graphics in a higher resolution,
  520. with still 256 colors, and two pages, for use with page-flipping !!
  521.  
  522.  
  523. ┌──────────────────────────────────────────────────────────────────────────────┐
  524. │░▒▓█ DISCLAIMER █▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
  525. └──────────────────────────────────────────────────────────────────────────────┘
  526.  
  527. Well, as usual, the author of this text is not responsible for any damage caused
  528. by the use or misuse of this text, bla, bla, har, har, nag, nag, etc.......
  529.  
  530.  
  531. ┌──────────────────────────────────────────────────────────────────────────────┐
  532. │░▒▓█ EPILOGUE ;) █▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
  533. └──────────────────────────────────────────────────────────────────────────────┘
  534.  
  535. Hey, when you do any productions, using above explanation or something,
  536. greet me !! I'd like that.....
  537.  
  538. You can usually contact me at EightBall, +31-546-829093, just write a private
  539. message to The Bitripper. If that doesn't work, Ash soon has got his board up
  540. and running again, so you can find me there also. I'll see you around...
  541.  
  542. Happy coding!
  543.  
  544.                         - The Bitripper -
  545.  
  546.  
  547. ┌──────────────────────────────────────────────────────────────────────────────┐
  548. │░▒▓█ GREETS █▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
  549. └──────────────────────────────────────────────────────────────────────────────┘
  550.  
  551. Greets go out to (alphabetical order):
  552.  
  553. Ash       - Hiya!
  554. Evil      - Long time no see (hear no Evil, see no Evil ;))
  555. HeXoN     - Having a good time?
  556. Lord Addu - Hear you've got another job?
  557. R.L.      - Don't know your current handle
  558.  
  559. and the rest of the people I forgot to mention here...
  560.